package org.dei.test.llqruntime.stack;

import java.util.*;
import org.dei.perla.parser.clauses.*;
import org.dei.perla.parser.statements.*;
import org.dei.perla.sys.device.fpc.*;
import org.dei.perla.sys.llqruntime.datastructures.*;
import org.dei.perla.utils.pipe.Pipe;


public class FPCmockup extends FPC{

	//Il device astratto dall'FPC
	private DeviceMockup pFakeDevice;
	
	//Mapping QueryDaServire <-> Attivita' di sampling
	private HashMap<LLStatement,SingleSamplingActivity> pActiveQueries = new HashMap<LLStatement,SingleSamplingActivity>();
 	
	//Costruttore
	public FPCmockup(String parText, DeviceMockup parDevice) {
		super(parText);
		this.pFakeDevice = parDevice;	
	}

	//Registra la query (i.e.: inizia a produrre)
	public void registerQueryOnFPC(LLStatement parStatement) {
		
		SingleSamplingActivity t = new SingleSamplingActivity(pFakeDevice);
		t.start();
		this.pActiveQueries.put(parStatement, t);
		
	}
	
	//Per l'interrogazione dal registry
	public QueryRecordStructure getFPCAttributes() {
		return pFakeDevice.getSamplableAttributes();
	}
	
	//Dovrebbe restituire il nome dell'FPC (A,B,C...)
	public String getFPCName() {
		return this.getName();
	}
	
	//Espone la pipe associate ad una query
	public Pipe<Record> getPipe(LLStatement parStatement) {
		return this.pActiveQueries.get(parStatement).getPipe();
	}

	//Setta la frequenza di produzione
	public boolean setMockupSamplingTime(long parTime,OnUnsupportedSampleRateOptions parBehaviour,LLStatement parStat) {
		this.pActiveQueries.get(parStat).setSamplingFrequency(parTime);
		return true;
		
	}
	
	//METODI EREDITATI, non importanti al momento.
	@Override
	protected void mngNormalMsg(byte[] parPayload) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public Pipe<Record> registerQuery(ArrayList<String> parAttrbiutesNames) {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public boolean setSamplingTime(long parTime,
			OnUnsupportedSampleRateOptions parBehaviour) {
		
		return true;
	}
		

}
